package schema

import (
	"time"

	"lianzi_gos/pkg/util"
)

// 轮播图表
type Banner struct {
	ID          string    `json:"id" gorm:"size:20;primarykey;"`                      // Unique ID
	Name        string    `json:"name" gorm:"size:128;index;default:'';comment:'名称'"` // Display name
	Img         string    `json:"img" gorm:"size:255;index;default:'';comment:'图片地址'"`
	Status      string    `json:"status" gorm:"size:20;index;comment:'enabled, disabled'"` // Status of  (enabled, disabled)
	Description string    `json:"description" gorm:"size:1024"`                            // Details about
	CreatedAt   time.Time `json:"created_at" gorm:"index;"`                                // Create time
	UpdatedAt   time.Time `json:"updated_at" gorm:"index;"`                                // Update time
}

// Defining the query parameters for the `Banner` struct.
type BannerQueryParam struct {
	util.PaginationParam
}

// Defining the query options for the `Banner` struct.
type BannerQueryOptions struct {
	util.QueryOptions
}

// Defining the query result for the `Banner` struct.
type BannerQueryResult struct {
	Data       Banners
	PageResult *util.PaginationResult
}

// Defining the slice of `Banner` struct.
type Banners []*Banner

// Defining the data structure for creating a `Banner` struct.
type BannerForm struct {
	Img         string `json:"img" binding:"required,max=132"`                   // Code of menu (unique for each level)
	Name        string `json:"name" binding:"required,max=128"`                  // Display name of menu
	Description string `json:"description"`                                      // Details about menu
	Status      string `json:"status" binding:"required,oneof=disabled enabled"` // Status of menu (enabled, disabled)

}

// A validation function for the `BannerForm` struct.
func (a *BannerForm) Validate() error {
	return nil
}

// Convert `BannerForm` to `Banner` object.
func (a *BannerForm) FillTo(banner *Banner) error {
	banner.Img = a.Img
	banner.Name = a.Name
	banner.Description = a.Description
	banner.Status = a.Status
	return nil
}
